﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xaml;
using System.ComponentModel.Design;

namespace SoftwareEngineering.Modeling
{
  public static class ModelReader
  {
    public static ModelBase ReadModel(string fileName)
    {
      var result = (ModelBase)XamlServices.Load(fileName);
      using (LazyActionExecutor executor = new LazyActionExecutor())
      {
        ServiceContainer container = new ServiceContainer();
        container.AddService(typeof(IRootProvider), (c, s) => new RootProvider(result));
        container.AddService(typeof(ILazyActionExecutor), executor);
        result.Initialize(container);
      }
      return result;
    }
  }
}
